package CCRMClient.GUI;

import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;

import java.awt.CardLayout;

import javax.swing.JLabel;
import javax.swing.JTextField;

import java.awt.FlowLayout;

import javax.swing.JScrollPane;
import javax.swing.JButton;

import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.SwingConstants;

import java.awt.Font;

public class MessagesScreen extends JPanel {
	private JTable table;
	private JScrollPane scrollPane; 
	private JButton btnReturnToMain;
	private JLabel lblMessages;
	public MessagesScreen() {
		setLayout(null);
		
		scrollPane = new JScrollPane();
		scrollPane.setBounds(10, 47, 430, 218);
		add(scrollPane);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null},
			},
			new String[] {
				"Sent from", "topic"
			}
		));
		table.getColumnModel().getColumn(0).setPreferredWidth(490);
		table.getColumnModel().getColumn(1).setPreferredWidth(490);
		table.addMouseListener(new MouseAdapter(){
			 public void mouseClicked(MouseEvent e) {
				 if (e.getClickCount() == 2) {
				      JTable target = (JTable)e.getSource();
				      int row = target.getSelectedRow();
				      
				 }
			 }
		});
		
		scrollPane.setViewportView(table);
		
		btnReturnToMain = new JButton("Return to main sreen");
		btnReturnToMain.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
			}
		});
		btnReturnToMain.setBounds(10, 276, 140, 23);
		add(btnReturnToMain);
		
		lblMessages = new JLabel("Messages");
		lblMessages.setFont(new Font("David", Font.BOLD, 26));
		lblMessages.setHorizontalAlignment(SwingConstants.CENTER);
		lblMessages.setBounds(150, 11, 155, 25);
		add(lblMessages);
	}
}
